package com.elinkway.infinitemovies.async;
import android.content.Context;

import com.elinkway.infinitemovies.bean.AppConfig;
import com.elinkway.infinitemovies.http.api.MoviesHttpApi;
import com.elinkway.infinitemovies.http.parser.AppConfigParser;
import com.lvideo.http.bean.LVideoDataHull;

public class RequestAppConfigTask extends MoviesHttpAsyncTask<AppConfig> {

    private RequestResultListener<AppConfig> mListener;

    public RequestAppConfigTask(Context context) {
        super(context);
    }

    @Override
    public LVideoDataHull<AppConfig> doInBackground() {
        return MoviesHttpApi.requestAppConfig(new AppConfigParser());
    }

    @Override
    public void onPostExecute(int updateId, AppConfig result) {
        if (null != mListener) {
            mListener.onRequestSuccess(updateId, result);
        }
    }

    @Override
    public void netNull() {
        super.netNull();
        if (null != mListener) {
            mListener.onRequestFailed();
        }
    }

    @Override
    public void netErr(int updateId, String errMsg) {
        super.netErr(updateId, errMsg);
        if (null != mListener) {
            mListener.onRequestFailed();
        }
    }

    @Override
    public void dataNull(int updateId, String errMsg) {
        super.dataNull(updateId, errMsg);
        if (null != mListener) {
            mListener.onRequestFailed();
        }
    }

    public RequestResultListener<AppConfig> getmListener() {
        return mListener;
    }

    public void setmListener(RequestResultListener<AppConfig> mListener) {
        this.mListener = mListener;
    }
}
